<?php

namespace common\models\user;

use Yii;

/**
 * This is the model class for table "{{%user_address}}".
 *
 * @property int $id
 * @property string $user_id 用户ID
 * @property string $name 收件人姓名
 * @property string $mobile 手机号
 * @property string $province 省份
 * @property string $city 市
 * @property string $district 地区
 * @property string $address_detail 详细地址
 * @property string $area_code 地区码
 * @property string $postal_code 邮编
 * @property int $is_default 是否默认地址
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 */
class UserAddress extends \common\db\ActiveRecord {

    use \common\traits\Constants;

    const STATUS_DELETED = -1;
    const STATUS_DEFAULT = 0;
    const STATUS_ACTIVE = 10;

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%user_address}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['user_id', 'is_default', 'created_at', 'updated_at'], 'integer'],
            [['name', 'mobile', 'province', 'city', 'district', 'address_detail'], 'required'],
            [['name', 'province', 'city', 'district'], 'string', 'max' => 50],
            [['mobile'], 'string', 'max' => 11],
            [['address_detail'], 'string', 'max' => 255],
            [['area_code'], 'string', 'max' => 10],
            [['postal_code'], 'string', 'max' => 6],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '用户ID',
            'name' => '收件人姓名',
            'mobile' => '手机号',
            'province' => '省份',
            'city' => '市',
            'district' => '地区',
            'address_detail' => '详细地址',
            'area_code' => '地区码',
            'postal_code' => '邮编',
            'is_default' => '是否默认地址',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }

}
